package com.github.chirspan.xaas.mybatis.dao;


import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

/**
 * @author chenpan
 * @ClassName: CommonDao
 * description:
 * @date 2018-04-02 15:56
 */
@Mapper
public interface CommonDao {

    /**
     * 获取序列值
     *
     * @param seqName
     * @return
     */
    @Select("select ${seqName}.nextval from dual")
    Integer getSequence(@Param("seqName") String seqName);

    /**
     * 调用存储过程
     *
     * @param procName
     */
    @Select("{ call ${_parameter} }")
    @Options(statementType = StatementType.CALLABLE)
    void callProcedure(String procName);

    /**
     * 根据sql返回map
     */
    @Select("${value}")
    Map<String, Object> query4Map(String sql);

    /**
     * 根据sql返回List<Map>
     */
    @Select("${value}")
    List<Map<String, Object>> query4ListMap(String sql);

    /**
     *
     * @param countSql
     * @return
     */
    @Select("${countSql}")
    int execCountSql(@Param("countSql") String countSql);

    @Update("${sql}")
    void execSql(@Param("sql") String sql);

}
